Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement test script #34

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Implement test script #34

wants to merge 4 commits into from

Conversation

monsieuremre
Copy link
Collaborator

Solves #27.

First three points are solved in completion. For it to work, the script test.py should be called like one normally would. python3 test.py /path/to/test.aasx. A custom test.aasx has to be pushed also as the subject. It can have any format, it does not need to be hardcoded or anything.

Potential solution for the last part is also added but commented out, because there is no direct way of closing the dialog window properly. I have implemented a time out mechanism here. Which is a nice workaround, but it is a sub-optimal solution at best.

More intricate ways are possible, still in code, but this would come with more disadvantages than what it would provide. A not so much complicated solution would be maybe using pytest-qt. This would mean that we can just emulate user keyboard strokes and mouse clicks. This would actually be very good solution, but it would force some hardcoding of sorts. We can change our ways to this if it would be desired.

@monsieuremre
Copy link
Collaborator Author

It is also trivial to call the script from a github workflow and set it to trigger after every push, needless to say. I can continue with this and push the test script if the current state is satisfactory. Else, I can look into more intricate options that I mentioned.

@zrgt
Copy link
Collaborator

zrgt commented Jun 17, 2024

@monsieuremre please try with pytest-qt. As a test file use the following one: https://github.com/rwth-iat/aas-compliance-tool/blob/main/test/files/test_demo_full_example.json

@monsieuremre
Copy link
Collaborator Author

I have managed to use pytest and qtbot to emulate some stuff. The test has to be called with pytest -s now, so it is not executed directly. We still do the iterating the old way as implemented. We also test if the window becomes visible with the bot as the first test, very basic.

Any further function is still a weak concept because these widgets are very detailed objects and I do not which one to choose and how to interact, since there is no documentation. I still figured out 'some' ways by trial and error and reverse engineering.

I have implemented several functions to find and select buttons based on their names. When I click these buttons, unfortunately, I can't get the expected behavior. I am not sure of the reason but I will look into it. I highly suspect I have to do a little more than just clicking or I'm clicking on the wrong widget. I will need to read the source code more in detail to understand the exact reason.

Copy link
Collaborator

@zrgt zrgt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Split the main into small distinct self-describing funcs
  • Integrate the testing into aas_editor_test/main_test.py
  • Use unittest framework
  • Add the following JSON aas_test_file.json and XML aas_test_file.txt (change format to XML) files and use them as example files
  • Remove other example files from aas_editor_test/aas_files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants